package main

import (
	"fmt"
	"runtime"
)

/*
*
Goexit函数，立即终止当前goroutine,调度器确保所有已注册 defer 延迟调用被执行。
*/
func main() {
	//go fun1()
	go func(a int, b int) bool {
		return true
	}(10, 20)
	//死循环，目的不让主goroutine结束
	for {

	}
}

func fun1() {
	defer fmt.Println("A.defer")
	fun2()
	fmt.Println("A")
}

func fun2() {
	defer fmt.Println("B.defer")
	runtime.Goexit()
	fmt.Println("B")
}
